import com.qi.dao.StudentMapper;
import com.qi.dao.TeacherMapper;
import com.qi.pojo.Student;
import com.qi.pojo.Teacher;
import com.qi.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

/**
 * @author zjq
 * @date 2020/3/11 15:46
 */
public class UserMapperText {
    public static void main(String[] args) {
        //使用注解查询寻
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        TeacherMapper mapper = sqlSession.getMapper(TeacherMapper.class);
        Teacher teacher = mapper.getTeacher(1);
        System.out.println(teacher);
        sqlSession.close();
    }

    @Test
    public void studentTest() {
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        StudentMapper Mapper = sqlSession.getMapper(StudentMapper.class);
        List<Student> studentList = Mapper.getStudent();
        for (Student student : studentList) {
            System.out.println(student);
        }
        sqlSession.close();
    }

    @Test
    public void TeacherTest() {
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        TeacherMapper mapper = sqlSession.getMapper(TeacherMapper.class);
        Teacher teacher = mapper.getTeacher(1);
        System.out.println(teacher);
        sqlSession.close();
    }

    @Test
    public void studentTest2() {
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        StudentMapper Mapper = sqlSession.getMapper(StudentMapper.class);
        List<Student> studentList = Mapper.getStudent2();
        for (Student student : studentList) {
            System.out.println(student);
        }
        sqlSession.close();
    }

}
